package com.shop2cn.iapi.coupon.service;

import org.json.JSONObject;

import com.shop2cn.iapi.coupon.parameter.batchInfos;
import com.ymatou.promotion.api.parameter.SellerCouponValueList;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
/**
*获取所有商家可以领取的批次Call
*FreeMaker Template自动生成代码
*/
public class GetAllSellerBatchInfosCall extends YmatouBaseCall{
	private static String opurl ="api/Promotion/GetAllSellerBatchInfos";
	
	public GetAllSellerBatchInfosCall() {
		super(EnvSetup.getSystemUrl("coupon_shop2cn_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("statusCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}
	
	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("message");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}
	
	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public String getData() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}
	
	/**
	 * 获取SellerCouponValueList
	 * @return
	 */
	public batchInfos getSellerCouponValueList() {
		batchInfos data = null;
		try {
			data = (batchInfos) FormatUtil.GSONToObject(getString("data"), batchInfos.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return data;
	}
}